<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:c="http://java.sun.com/jsp/jstl/core">

  
<ui:composition template="../templates/template_menu.xhtml">
    
    <ui:define name="scripts">
        <script language="javascript" type="text/javascript" src="../scripts/funciones_paises.js"></script>       
    </ui:define>
    
    <ui:define name="title">      
        <f:loadBundle basename="org.me.resources.messages" var="msg"/>
        <h:outputText value="#{msg.paises}" />        
    </ui:define>
    
    <ui:define name="content">           
     <f:view>        
            <a4j:form id="frmMantenimientoPaises">
               
               <rich:panel  style="margin-left: 30px;margin-top: 30px; width:430px;border:0px solid #14527e;border-radius: 20px;box-shadow:rgba(100,100,100,0.4)10px 10px ; height : 205px;" >
                  <!-- Describe si ya existe el pais a grabar -->
                  <h:outputText id="paisExiste" value="#{mantenimientoPaisesController.paisExiste}" style="font-weight:bold;
                             color:#{mantenimientoPaisesController.color};"/>  
                  <h:panelGrid columns="2" >
                      <h:outputText value="#{msg.mantenimientoPaises}"  style="color: #999999;font-weight: bold;font-family: Tahoma;font-size: 13px;"  />			
                  </h:panelGrid>
                  <br/>
                  <h:panelGrid columns="1" border="1" bgcolor="yellow" title="#{msg.datosGeneralesPais}" >
                      <f:facet name="header">
                         <h:outputText value="#{msg.datosGeneralesPais}"/>
                      </f:facet>
                      
                      <h:panelGroup>
                         <h:outputText value="#{msg.idpais}" />                      
                         <h:inputText id="idPais" value="#{mantenimientoPaisesController.id_pais}" readonly="true" /> 
                      </h:panelGroup>
                      
                      <h:panelGroup>
                          <h:outputText value="#{msg.nompais}" styleClass="campoObligatorio" />
                          <h:inputText id="nomPais" value="#{mantenimientoPaisesController.nom_pais}" size="40" maxlength="70" />                                                    
                      </h:panelGroup>                                            
                      
                      <h:panelGroup>
                          <h:outputText value="#{msg.numhabitantes}" styleClass="campoObligatorio"  />
                          <h:inputText  id="numHabitantes" value="#{mantenimientoPaisesController.num_habitantes}" onkeypress="return validarNumeros(event)"
                                              size="10" maxlength="12"   />                                                    
                      </h:panelGroup>
                  </h:panelGrid>
                  
                  <h:panelGrid columns="2">                    
                      
                     <h:commandButton id="btnGrabar" value="#{msg.grabar}" actionListener="#{mantenimientoPaisesController.grabaOActualizaPais}" 
                                       onclick="return validarCampos_Paises();" styleClass="spacio" >
                          <a4j:support event="onclick" reRender="datable,frmMantenimientoPaises" />
                          <rich:toolTip for="btnGrabar" value="#{msg.grabar}" />
	             </h:commandButton>
                      
                     <a4j:commandButton value=" #{msg.limpiar} "  id="btnLimpiar" 
                                       actionListener="#{mantenimientoPaisesController.clean}" reRender="frmMantenimientoPaises" styleClass="spacio"> 
			 <rich:toolTip for="btnLimpiar" value="#{msg.limpiar}" />
		     </a4j:commandButton>         
                     
		 </h:panelGrid>                       
                 
               </rich:panel>
               <br /> 
               
               <rich:panel  style=" margin-left: 30px;border:0px solid #14527e;border-radius: 20px;box-shadow:rgba(100,100,100,0.4)10px 10px ;width:430px;height : 395px;" >
                <!-- DataTable -->                  
                <h:panelGrid columns="1" id="datable">                         
                    <rich:datascroller for="mdr1" maxPages="5" rendered="#{not empty mantenimientoPaisesController.beanList}"/>
                    <rich:dataTable id="mdr1" value="#{mantenimientoPaisesController.beanList}"
		        var="item" rows="10" width="100%" dir="LTR" frame="hsides" styleClass="datatable"
			onRowMouseOver="this.style.backgroundColor='#c5dbf9'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
					rules="all" rowKeyVar="rowKey" cellspacing="5" rendered="#{not empty mantenimientoPaisesController.beanList}">
					
					<f:facet name="header">
						<h:outputText value="#{msg.listadoPaises}"/>
					</f:facet>
					
					<rich:column>
						<f:facet name="header">
							<h:outputText value="#{msg.numeral}" />
						</f:facet>
						<h:outputText value="#{rowKey+1}"></h:outputText> 
					</rich:column>
					
					<rich:column  >
						<f:facet name="header">
							<h:outputText value="#{msg.id}" />
						</f:facet>
						<h:outputText value="#{item.getNIdPaisPk()}"></h:outputText>
					</rich:column>                       
                        
					<rich:column sortBy="#{item.getVNombrePais()}" filterBy="#{item.getVNombrePais()}" filterEvent="onkeyup">
						<f:facet name="header">
							<h:outputText value="#{msg.nombre}" />
						</f:facet>
						<h:outputText value="#{item.getVNombrePais()}"></h:outputText>
					</rich:column>

					<rich:column sortBy="#{item.getNNumHabitantesPais()}">
						<f:facet name="header">
							<h:outputText value="#{msg.numhabitantes}"/>
						</f:facet>
						<h:outputText value="#{item.getNNumHabitantesPais()}"></h:outputText>
					</rich:column>
					
					<rich:column>
					   <f:facet name="header">
					      <h:outputText value="#{msg.accion}"/>
					   </f:facet>
                                           
                                            <!--faces-config.xml -->
					   <h:commandLink action="mantenimientoPaises" id="editLink" actionListener="#{mantenimientoPaisesController.load}" immediate="true">
                                              <h:graphicImage value="/images/editar.png" style="border:0px" styleClass="EspacioBotones" />
                                              <f:param name="sid1" id="sid1" value="#{item.getNIdPaisPk()}" />
                                              <rich:toolTip for="editLink" value="#{msg.editar} #{item.getVNombrePais()}"/>
					   </h:commandLink>
                                            
					   <h:commandLink action="mantenimientoPaises"  id="deleteLink" onclick="return confirmDelete();" 
                                                                      actionListener="#{mantenimientoPaisesController.delete}" immediate="true">
					      <h:graphicImage value="/images/eliminar.png" style="border:0px;" styleClass="EspacioBotones" />
					      <f:param name="sid2" id="sid2" value="#{item.getNIdPaisPk()}" />
					      <rich:toolTip for="deleteLink" value="#{msg.eliminar} #{item.getVNombrePais()}"/>						
					   </h:commandLink>
					</rich:column>
                                     
					<f:facet name="footer">
						<h:outputText value="#{msg.listan} #{msg.totalregistros} : #{mantenimientoPaisesController.numPaises}" />    
					</f:facet> 
                        
				</rich:dataTable>
		</h:panelGrid>              
                 <!-- fin DataTable-->                  
               </rich:panel>		
            </a4j:form>	        
        </f:view>
    </ui:define>   

</ui:composition>

</html>
 